<?php

/**
 * JingYao-backend
 *
 * @link     https://gitee.com/wang-zhihui-release/jingyao-backend
 * @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
 */

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCheckUserProfilesTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('check_user_profiles', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('phone', 20)->nullable();
            $table->string('sex', 5)->default('')->comment('1: man / 2:woman');
            $table->string('address')->nullable()->default('')->comment('详细地址');
            $table->dateTime('birthday')->nullable();
            $table->string('id_card_number', 20)->nullable();
            $table->string('native_place')->nullable()->comment('籍贯');
            $table->tinyInteger('marital_status')->nullable()->default(0)->comment('婚姻状态');
            $table->tinyInteger('has_children')->nullable()->default(0)->comment('有无子女');
            $table->tinyInteger('education')->nullable()->default(0)->comment('学历');
            $table->string('residence_place')->nullable()->comment('户口所在地');
            $table->dateTime('come_beijing_time')->nullable()->comment('来京时间');
            $table->string('now_address')->nullable()->comment('现居住地址');
            $table->string('company_name')->nullable()->comment('公司名称');
            $table->tinyInteger('industry')->nullable()->default(0)->comment('行业');
            $table->string('urgent_people')->nullable()->comment('紧急联系人');
            $table->string('urgent_people_phone')->nullable()->comment('紧急联系人电话');
            $table->tinyInteger('has_contribution')->default(0)->comment('有无贡献');
            $table->text('contribution')->nullable()->comment('具体贡献事迹');
            $table->tinyInteger('has_violated')->default(0)->comment('是否违纪');
            $table->text('violated_detail')->nullable()->comment('具体违纪事项');
            $table->tinyInteger('area')->default(0)->comment('所属片区');
            $table->tinyInteger('is_vaccination')->default(0)->comment('是否接种疫苗 1 接种 2 没有');
            $table->string('vaccination_screenshot_path')->nullable()->comment('接种疫苗截图');
            // 这两个字段和 user 表统一
            // 导入信息的时候 user_id 可以为空 自动或者手动绑定
            $table->integer('user_id')->default(0)->comment('关联的用户 user_id');
            $table->tinyInteger('identity')->default(0)->comment('1: 流动人口 2: 房东 3: 其他');
            $table->tinyInteger('check_status')->default(0)->comment('审核状态 1 通过 2 拒绝');
            $table->string('check_message')->default('')->comment('未通过原因');
            $table->timestamps();
            $table->index('user_id');
            $table->index('phone');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('check_user_profiles');
    }
}
